package com.elmcode.server.controller.admin;

import com.elmcode.common.utils.PageUtils;
import com.elmcode.common.utils.R;
import com.elmcode.server.entity.BookDetailEntity;
import com.elmcode.server.service.BookDetailService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 订单明细
 *
 * @author laozj
 * @email laozj@elm.com
 * @date 2024-06-13 13:05:04
 */
@Api(tags = "预定细节接口")
@RestController
@RequestMapping("user/bookdetail")
public class BookDetailController {
    @Autowired
    private BookDetailService bookDetailService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bookDetailService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		BookDetailEntity bookDetail = bookDetailService.getById(id);

        return R.ok().put("bookDetail", bookDetail);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody BookDetailEntity bookDetail){
		bookDetailService.save(bookDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody BookDetailEntity bookDetail){
		bookDetailService.updateById(bookDetail);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		bookDetailService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
